﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Core.Log;

namespace Core.Xml.Ogc.Ows
{
    // TODO :This implementation of ISO 19115 is not finished. It should be expanded and documented.
    // https://wiki.ceh.ac.uk/display/cehigh/Online+Resource
    // http://code.google.com/p/spitsuur/source/browse/trunk/sharpdevelop/wpsClient/wpsClient/OpenGIS/ows_11/OnlineResourceType.cs?r=70
    class OnlineResourceType : IXmlType
    {
        public string Href { get; set; }

        /// <summary>
        /// Creates the XElement of the instance with the given name.
        /// </summary>
        /// <param name="elementName">The name of the XElement</param>
        /// <returns>XElement of the instance with the given name</returns>
        public XElement CreateXElement(XName elementName)
        {
            if (String.IsNullOrEmpty(Href))
            {
                Logger logger = Logger.GetInstance();
                logger.Add(new BasicLog(LogPriority.WARNING, "The href of the OnlineResource must not be left empty according to the standards."));
            }
            XElement onlineResource = new XElement(elementName);
            onlineResource.Add(new XAttribute(Xml.Namespaces.XLINK + "href", Href));
            return onlineResource;
        }
    }
}
